package com.shiro.shiroweb.service;

import com.shiro.shiroweb.dao.PermissionRepository;
import com.shiro.shiroweb.dao.RoleRepository;
import com.shiro.shiroweb.dao.UserRepository;
import com.shiro.shiroweb.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

@Service
public class LoginService {
    @Autowired
    private UserRepository userRepository;
    @Autowired
    private RoleRepository roleRepository;
    @Autowired
    private PermissionRepository permissionRepository;

    /**
     * 根据用户名查询用户信息
     * @param username
     * @return
     */
    public UserEntity findByName(String username) {
        return userRepository.findByName(username);
    }

    public Set<String> findRolesByUsername(String username) {
        return roleRepository.findRolesByUsername(username);
    }

    public Set<String> findPermissionByUsername(String username) {
        return permissionRepository.findPermissionByUsername(username);
    }
}
